package com.jt.controller;

import com.jt.pojo.Rights;
import com.jt.service.RightsService;
import com.jt.vo.SysResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author: taoyi
 * @date: 2021/6/10 14:15
 * @version: 1.0
 * @explain:
 */
@RestController
@CrossOrigin // 跨域资源共享
@RequestMapping("/rights")
public class RightsController {

    @Autowired
    private RightsService rightsService;

    /**
     * 测试
     * @return
     */
    @GetMapping("/list")
    public List<Rights> list(){
        return rightsService.list();
    }

    /**
     * 查询左侧权限列表数据，要求查询2级表数据
     * URL： /rights/getRightsList
     * 参数：null
     * 返回值：SysResult 对象
     */
    @GetMapping("/getRightsList")
    public SysResult getRightsList(){
        List<Rights> list = rightsService.getRightsList();
        return SysResult.success(list);
    }

    @GetMapping("/getRightsList2")
    public SysResult getRightsList2(){
        List<Rights> list = rightsService.getRightsList();
        System.out.println(list);
        return SysResult.success(list);
    }

}
